package com.itheima;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @auther Macrydy
 * @date 2020/7/11 14:21
 */
public class ThreadPool01 {
    public static void main(String[] args) {
        //默认线程池
        ExecutorService es = Executors.newCachedThreadPool();

        //执行线程，需要传入Runnable对象
        es.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName()+"执行了");
            }
        });

        es.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName()+"执行了");
            }
        });

        //关闭线程池
        es.shutdown();
    }
}
